package org.jeecg.modules.smartschoolpoverty.service.impl;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import org.jeecg.modules.pinkun.entity.DiyPinkun;
import org.jeecg.modules.smartschoolpoverty.entity.SmartSchoolPoverty;
import org.jeecg.modules.smartschoolpoverty.mapper.SmartSchoolPovertyMapper;
import org.jeecg.modules.smartschoolpoverty.service.ISmartSchoolPovertyService;
import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import java.text.SimpleDateFormat;

/**
 * @Description: 贫困认定申请表
 * @Author: jeecg-boot
 * @Date:   2022-01-14
 * @Version: V1.0
 */
@Service
public class SmartSchoolPovertyServiceImpl extends ServiceImpl<SmartSchoolPovertyMapper, SmartSchoolPoverty> implements ISmartSchoolPovertyService {

    @Override
    public void saveAllInfo(JSONArray form_component_values) {
        {
            SmartSchoolPoverty diyPinkun = new SmartSchoolPoverty();
            for (int i = 0; i < form_component_values.size(); i++) {
                JSONObject jsonObject = form_component_values.getJSONObject(i);
                String name = jsonObject.getString("name");
                String value = jsonObject.getString("value");
                SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
                try {
                    switch (name){
                        case "学号":
                            diyPinkun.setStudentNumber(value);
                            break;
                        case "姓名":
                            diyPinkun.setStudentName(value);
                            break;
                        case "性别":
                            diyPinkun.setStudentSex(value);
                            break;
                        case "出生年月":
                            diyPinkun.setStudnetBirthday(sdf.parse(value));
                            break;
                        case "民族":
                            diyPinkun.setStudentNation(value);
                            break;
                        case "身份证账号":
                            diyPinkun.setStudentIdCard(value);
                            break;
                        case "政治面貌":
                            diyPinkun.setStudentZzmm(value);
                            break;
                        case "家庭人口数":
                            diyPinkun.setStudentJreks(value);
                            break;
                        case "在校月开销":
                            diyPinkun.setStudentZxykx(value);
                            break;
                        case "是否建档立卡":
                            diyPinkun.setStudentSfjdlk(value);
                            break;
                        case "入学前户口（农村/城镇）":
                            diyPinkun.setStudentRxqhk(value);
                            break;
                        case "是否单亲":
                            diyPinkun.setStudentSfdc(value);
                            break;
                        case "是否孤残":
                            diyPinkun.setStudentSfgc(value);
                            break;
                        case "是否烈士或优抚对象子女":
                            diyPinkun.setStudentSflshyfdxzn(value);
                            break;
                        case "家庭人均年收入":
                            diyPinkun.setStudentJtrjnsr(value);
                            break;
                        case "系":
                            diyPinkun.setStudentDeparment(value);
                            break;
                        case "专业":
                            diyPinkun.setStudentProfessor(value);
                            break;
                        case "邮政编码":
                            diyPinkun.setStudentYzemail(value);
                            break;
                        case "在校联系电话":
                            diyPinkun.setStudentPhoneschool(value);
                            break;
                        case "家庭成员情况":
                            diyPinkun.setStudentJtcyqk(value);
                            break;
                        case "影响家庭经济状况有关信息":
                            diyPinkun.setStudentYxjtjjzkygxx(value);
                            break;
                        case "学生陈述申请认定理由":
                            diyPinkun.setStudentLy(value);
                            break;
                        case "评议小组意见":
                            diyPinkun.setStudentPyxzyjstring(value);
                            break;
                    }

                }catch (Exception e){
                    e.printStackTrace();
                }
            }
            // 插入
            baseMapper.insert(diyPinkun);

        }
    }
}
